<template>
  <el-drawer
    :model-value="isVisible"
    size="50%"
    @close="handleClose"
  >
    <template #header>
      <slot name="header" />
    </template>
    <el-scrollbar>
      <slot></slot>
    </el-scrollbar>
    <template #footer>
      <div style="flex: auto;">
        <el-button
          v-blur
          type="primary"
          :icon="CloseBold"
          @click="handleCancel"
        >
          取消
        </el-button>
        <el-button
          v-blur
          type="primary"
          :icon="Select"
          @click="handleSave"
        >
          保存
        </el-button>
      </div>
    </template>
  </el-drawer>
</template>

<script lang="ts" setup>
import { Select, CloseBold } from '@element-plus/icons-vue'
defineProps<{
  isVisible: boolean
}>()
const emits = defineEmits<{
  (e: 'closeDrawer', isVisible: boolean): void
  (e: 'saveDrawer'): void
}>()
const handleClose = () => {
  emits('closeDrawer', false)
}
const handleCancel = () => {
  handleClose()
}
const handleSave = () => {
  emits('saveDrawer')
}
</script>

<style lang="scss" scoped>
$color: #fff;
:deep(.el-form-item__label) {
  color: $color;
}
:deep(.el-button) {
  background: transparent;
}
</style>
